#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import multiprocessing
import time


def myprint(obj):
    sys.stdout.write(str(obj) + '\n')


def worker():
    name = multiprocessing.current_process().name
    myprint(' '.join((name, 'Starting')))
    time.sleep(2)
    myprint(' '.join((name, 'Exiting')))


def my_service():
    name = multiprocessing.current_process().name
    myprint(' '.join((name, 'Starting')))
    time.sleep(3)
    myprint(' '.join((name, 'Exiting')))


if __name__ == '__main__':
    service = multiprocessing.Process(name='my_service',
            target=my_service)
    worker_1 = multiprocessing.Process(name='worker 1', target=worker)
    worker_2 = multiprocessing.Process(target=worker)  # use default name

    worker_1.start()
    worker_2.start()
    service.start()
